//
//  runTimeViewController.m
//  IOSDome
//
//  Created by clobe on 2019/4/15.
//  Copyright © 2019 clobe. All rights reserved.
//

#import "runTimeViewController.h"
#import "UIButton+Action.h"

#import "runTimeToViewController.h"

#import "statisticalTimeViewController.h"

#import "arrayTraverseViewController.h"

static NSString *keyOfMethod;
static NSString *keyOfBlock;

@interface runTimeViewController ()

@end

@implementation runTimeViewController
{
    int index;
    UIView *showView;
}


-(instancetype)init{
    
    self = [super initWithNibName:@"runTimeViewController" bundle:[self wg_subBundleWithBundleName:@"runTimeViewController" targetClass:[self class]]];
    
    if (self){
    }
    return self;
}


- (instancetype)wg_subBundleWithBundleName:(NSString *)bundleName targetClass:(Class)targetClass{
    //并没有拿到子bundle
    NSBundle *bundle = [NSBundle bundleForClass:targetClass];
    //在这个路径下找到子bundle的路径
    NSString *path = [bundle pathForResource:bundleName ofType:@"bundle"];
    //根据路径拿到子bundle
    return path?[NSBundle bundleWithPath:path]:[NSBundle mainBundle];
    
    /*
     这种方式也可以
     NSBundle *bundle = [NSBundle bundleForClass:targetClass];
     NSURL *url = [bundle URLForResource:bundleName withExtension:@"bundle"];
     return path?[NSBundle bundleWithURL:url]:[NSBundle mainBundle];
     */
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    index = 0;
    [self uiConfig];
    // Do any additional setup after loading the view.
    
    showView = (UIView *)[self.view viewWithTag:1000];
    
}

- (IBAction)btnActionC:(id)sender {
    NSSet *set = [NSSet setWithObjects:[UIColor redColor],[UIColor blueColor],[UIColor whiteColor], nil];
    UIColor *col =[set anyObject];
    [showView setBackgroundColor:col];
}

- (void)uiConfig{
    //第一个按钮
    UIButton *button1 = [UIButton createBtnWithFrame:CGRectMake((SCREEN_WIDTH - 100)/2, (SCREEN_HEIGHT - 50)/2 - 150, 100, 50) title:@"按钮" actionBlock:^(UIButton *button) {
//        self.view.backgroundColor = [UIColor blueColor];
        if(self->index == 0){
            for (int i = 0; i<100000; i++) {
                NSLog(@"输出");
            }
        }
        self->index++;
        [self.navigationController pushViewController:[[runTimeToViewController alloc] init] animated:YES];
    }];
    button1.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:button1];
    
    //第二个按钮
    UIButton *button2 = [UIButton createBtnWithFrame:CGRectMake((SCREEN_WIDTH - 100)/2, CGRectGetMaxY(button1.frame) + 20, 100, 50) title:@"按钮2" actionBlock:nil];
    button2.actionBlock = ^(UIButton *button){
        NSLog(@"---%@---",button.currentTitle);
        
//        [self.navigationController pushViewController:[[statisticalTimeViewController alloc] init] animated:YES];
        [self.navigationController pushViewController:[[arrayTraverseViewController alloc] init] animated:YES];
    };
    button2.backgroundColor = [UIColor lightGrayColor];
    [self.view addSubview:button2];
}


@end
